#ifndef xpack_lang_cxx_clone
#define xpack_lang_cxx_clone
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::lang_cxx::inc
#include"define/base_type.hpp"
#include"lang/cxx.hpp"
#include"macro/xunlikely.hpp"
#include"memop/copy.hpp"
#pragma pop_macro("xuser")

namespace mixc::lang_cxx{
    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::clone(xalloc_t const & alloc) const {
        auto length     = uxx(xthe->length);
        auto result     = the_t{};
        auto allocx     = the_t::helper::stream_helper(alloc, xmodify(result.m_ptr), xmodify(result.m_length));
        auto stream     = allocx(length);

        if (stream != nullptr){
            stream.output(m_ptr, m_length);
        }

        if constexpr (inc::is_same<ret_t, the_t>){
            return result;
        }
    }
}

#endif
